package com.lg.partition35;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/5/12 10:16
 */
public class P3478POI2008_STAStation {

    private static final int N = 1000010, M = 2 * N;
    private static int[] h = new int[N], e = new int[M], ne = new int[M], dep = new int[N];
    private static long[] size = new long[N], f = new long[N];
    private static int n, idx = 0;

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = nextInt();
        Arrays.fill(h, -1);
        for (int i = 0; i < n - 1; i++) {
            int a = nextInt(), b = nextInt();
            add(a, b);
            add(b, a);
        }
        dfsdown(1, 0);
        for (int i = 1; i <= n; i++) f[1] += dep[i];
        dfsup(1, 0);
        long maxs = 0;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (maxs < f[i]) {
                maxs = f[i];
                ans = i;
            }
        }
        writer.println(ans);
        writer.flush();
    }

    private static void dfsup(int u, int fa) {
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v == fa) continue;
            f[v] = f[u] - size[v] + n - size[v];
            dfsup(v, u);
        }
    }

    private static void dfsdown(int u, int fa) {
        size[u] = 1;
        dep[u] = dep[fa] + 1;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v == fa) continue;
            dfsdown(v, u);
            size[u] += size[v];
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }

    private static int nextInt() throws IOException {
        tokenizer.nextToken();
        return (int) tokenizer.nval;
    }
}
